<template>
  <!-- 物流信息 -->
  <div id="courier">
    <el-dialog
      title="物流信息"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :show-close="true"
    >
      <el-timeline :reverse="reverse">
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :timestamp="activity.timestamp"
        >{{activity.content}}</el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["visible"],
  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },
      set(value) {
        this.$emit("update:visible", value);
      }
    }
  },
  data() {
    return {
      reverse: true,
      activities: [
      ]
    };
  },
  methods: {
    init(id) {
      this.activities = [];
      this.$https.get("order/getCourier", { id: id }).then(res => {
        if (res.data.data && res.data.data.courierDetails) {
          let courierDetails = res.data.data.courierDetails;
          courierDetails.forEach(element => {
            this.activities.push({
              content: element.context,
              timestamp: element.time
            });
          });
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
